<template lang="">
    <div>
        <van-field label='手机号' v-model='form.mobile'/>
        选择角色
        <select v-model="form.role_id">
            <option :value="i.id" v-for="i in rolelist">{{i.name}}</option>
        </select>
        <van-button @click='add'>添加</van-button>
    </div>
</template>
<script>
export default {
    data(){
        return{
            form:{},
            rolelist:[]
        }
    },
    methods: {
        //获取角色列表
        getRoles(){
            this.axios.get('roleM').then(res=>{
                this.rolelist = res.data.list
            })
        },
        add(){
            this.axios.post('adminuserM',this.form).then(res=>{
                if(res.data.code == 200){
                    alert('添加成功')
                    this.form = {}
                }
            })
        }
    },
    mounted() {
        this.getRoles()
    },
}
</script>
<style lang="">
    
</style>